/**
 * 初始化文档类型详情对话框
 */
var CdcDoctypeInfoDlg = {
    validateFields: {
    	code: {
            validators: {
                notEmpty: {
                    message: '代码不能为空'
                }
            }
        },
    	description: {
            validators: {
                notEmpty: {
                    message: '描述不能为空'
                }
            }
        },
    	note: {
            validators: {
                notEmpty: {
                    message: '备注不能为空'
                }
            }
        },
    	isActive: {
            validators: {
                notEmpty: {
                    message: '是否有效不能为空'
                }
            }
        },
    }
};


/**
 * 关闭此对话框
 */
CdcDoctypeInfoDlg.close = function() {
    parent.layer.close(parent.layer.getFrameIndex(window.name)); //先得到当前iframe层的索引,再执行关闭   
}

/**
 * 验证数据是否为空
 */
CdcDoctypeInfoDlg.validate = function () {
    $('#cdcDoctypeInfoForm').data("bootstrapValidator").resetForm();
    $('#cdcDoctypeInfoForm').bootstrapValidator('validate');
    return $("#cdcDoctypeInfoForm").data('bootstrapValidator').isValid();
}

/**
 * 提交新增
 */
CdcDoctypeInfoDlg.addSubmit = function() {

    if (!this.validate()) {
        return;
    }
    //提交信息
    Sys.ajaxForm('cdcDoctypeInfoForm',Sys.backendPath + "/cdc/cdcdoctype/add",function(res) {
        Sys.success(res.message);
    	window.parent.CdcDoctype.table.refresh();
        CdcDoctypeInfoDlg.close();
    });
}

/**
 * 提交修改
 */
CdcDoctypeInfoDlg.editSubmit = function() {

    if (!this.validate()) {
        return;
    }
    //提交信息
    Sys.ajaxForm('cdcDoctypeInfoForm',Sys.backendPath + "/cdc/cdcdoctype/update",function(res) {
        Sys.success(res.message);
    	window.parent.CdcDoctype.table.refresh();
        CdcDoctypeInfoDlg.close();
    });
}

$(function() {
	Sys.initValidator("cdcDoctypeInfoForm", CdcDoctypeInfoDlg.validateFields);
});
